
DROP SEQUENCE nextid
/

CREATE SEQUENCE nextid
  INCREMENT BY 1
  START WITH 30000
  MINVALUE 30000
/


CREATE OR REPLACE TRIGGER orders_insert
 BEFORE
  INSERT
 ON orders
REFERENCING NEW AS NEW OLD AS OLD
 FOR EACH ROW
BEGIN
   SELECT nextid.NEXTVAL
     INTO :NEW.orderid
     FROM DUAL;
END;
/


CREATE OR REPLACE TRIGGER employees_insert
 BEFORE
  INSERT
 ON employees
REFERENCING NEW AS NEW OLD AS OLD
 FOR EACH ROW
BEGIN
   SELECT nextid.NEXTVAL
     INTO :NEW.employeeid
     FROM DUAL;
END;
/


CREATE OR REPLACE TRIGGER testtable1_insert
 BEFORE
  INSERT
 ON testtable1
REFERENCING NEW AS NEW OLD AS OLD
 FOR EACH ROW
BEGIN
   SELECT nextid.NEXTVAL
     INTO :NEW.ID
     FROM DUAL;
END;
/



